package com.linjacy.httpproject.config;

import com.linjacy.httpproject.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class InterceptorConfig extends WebMvcConfigurerAdapter {
//    @Bean
//    public AuthInterceptor authInterceptor(){
//        return new AuthInterceptor();
//    }
    @Autowired
    AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置你要拦截的资源，这里拦截全路径
        registry.addInterceptor(authInterceptor).addPathPatterns("/**")
                .excludePathPatterns(                         //添加不拦截路径
                        "/**/*.html",            //html静态资源
                        "/**/*.js",              //js静态资源
                        "/**/*.css",             //css静态资源
                        "/**/*.woff",
                        "/**/*.ttf"
                );
    }
}
